]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
cleanup: Replace deprecated String.prototype.substr()
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 5 Mar 2024 19:20:49 +0000 (20:20 +0100)
committerMarge Bot <marge-bot@gnome.org>
Fri, 19 Apr 2024 17:38:37 +0000 (17:38 +0000)
The method is documented as deprecated:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr

Switch to the non-deprecated substring() method.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3234>

js/misc/dbusUtils.js
js/ui/calendar.js
js/ui/messageList.js
js/ui/runDialog.js

index 2813de2a768243c12492795440032eee7005d44f..6e15f9e147e73bb2b2bc5126b525cab301782330 100644 (file)
@@ -62,6 +62,6 @@ export function loadSubInterfaceXML(iface, ifaceFile) {
 
     return (
         xmlHeader +
-        xml.substr(ifaceStartIndex, ifaceEndIndex - ifaceStartIndex) +
+        xml.substring(ifaceStartIndex, ifaceEndIndex) +
         xmlFooter);
 }
index fa683de0c0b5596fec090c6635e3419467c5a8b7..43079ed6df3a1cb6351eb332ec372be3b5d2f81e 100644 (file)
@@ -319,7 +319,7 @@ class DBusEventSource extends EventSourceBase {
             let event = new CalendarEvent(id, date, end, summary);
             /* It's a recurring event */
             if (!id.endsWith('\n')) {
-                const parentId = id.substr(0, id.lastIndexOf('\n') + 1);
+                const parentId = id.substring(0, id.lastIndexOf('\n') + 1);
                 if (!handledRemovals.has(parentId)) {
                     handledRemovals.add(parentId);
                     this._removeMatching(parentId);
index acc50331936bcfede6d3587c8e9a27893421dc3d..dda9f22a9b96dbaaa20d3c0623bda22193250c36 100644 (file)
@@ -57,7 +57,7 @@ class URLHighlighter extends St.Label {
         this.connect('style-changed', () => {
             let [hasColor, color] = this.get_theme_node().lookup_color('link-color', false);
             if (hasColor) {
-                let linkColor = color.to_string().substr(0, 7);
+                let linkColor = color.to_string().substring(0, 7);
                 if (linkColor !== this._linkColor) {
                     this._linkColor = linkColor;
                     this._highlightUrls();
@@ -143,11 +143,11 @@ class URLHighlighter extends St.Label {
         let pos = 0;
         for (let i = 0; i < urls.length; i++) {
             let url = urls[i];
-            let str = this._text.substr(pos, url.pos - pos);
+            let str = this._text.substring(pos, url.pos);
             markup += `${str}<span foreground="${this._linkColor}"><u>${url.url}</u></span>`;
             pos = url.pos + url.url.length;
         }
-        markup += this._text.substr(pos);
+        markup += this._text.substring(pos);
         this.clutter_text.set_markup(markup);
     }
 
index 6676087964d0e0ca53d4df41fdc268d520bb44ef..29a015b166e8b7ed64e0418da3e69dfc99649fdd 100644 (file)
@@ -107,7 +107,7 @@ class RunDialog extends ModalDialog.ModalDialog {
                 if (text.lastIndexOf(' ') === -1)
                     prefix = text;
                 else
-                    prefix = text.substr(text.lastIndexOf(' ') + 1);
+                    prefix = text.substring(text.lastIndexOf(' ') + 1);
                 let postfix = this._getCompletion(prefix);
                 if (postfix != null && postfix.length > 0) {
                     o.insert_text(postfix, -1);
@@ -143,7 +143,7 @@ class RunDialog extends ModalDialog.ModalDialog {
             }
             if (k === 0)
                 return '';
-            return s1.substr(0, k);
+            return s1.substring(0, k);
         }
 
         let paths = GLib.getenv('PATH').split(':');
@@ -172,7 +172,7 @@ class RunDialog extends ModalDialog.ModalDialog {
             return null;
 
         let common = results.reduce(_getCommon, null);
-        return common.substr(text.length);
+        return common.substring(text.length);
     }
 
     _getCompletion(text) {